package com.example.demo.service.serviceImpl;

import com.example.demo.pojo.Stats;
import com.example.demo.repository.StatsRepository;
import com.example.demo.service.StatsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class StatsServiceImpl implements StatsService {

    @Autowired
    private StatsRepository statsRepository;

    @Override
    public Integer countLogin() {
        return statsRepository.countAll();
    }

    @Override
    public Integer countLoginByTime(Date date1, Date date2) {
        return statsRepository.countAllByTime(date1, date2);
    }

    @Override
    public void addStats(String account) {
        Stats stats = new Stats();
        stats.setS_account(account);
        stats.setS_time(new Date());
        statsRepository.save(stats);
    }
}
